<script type="text/javascript" src="/admin/public/js/art_dialog/artDialog.source.js?skin=blue"></script>
<script type="text/javascript" src="/admin/public/js/art_dialog/plugins/iframeTools.source.js"></script>
<script type="text/javascript" src="/admin/public/js/art_dialog/_doc/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/admin/public/js/art_dialog/_doc/highlight/languages/javascript.js"></script>
<link rel="stylesheet" type="text/css" href="/admin/assets/307e2003/css/common.css" />
<div class="common_form"    >

			 <table cellpadding="0" >
				<tbody>

					<tr>
					<td>
						<?php $this->widget('ext.autowidget'); ?>
						<input type="text" class="autokey" id='search'  />
						&nbsp;&nbsp;
					    <input type="button" class="default_btn" id='submit'  value="搜索"/>
						<input type="hidden" class="default_btn" id='hid'  value="<?php echo $uclass;?>"/>
					    <?php  $this->widget('ext.uploadify',array("ext"=>'*.gif;*.jpg;*.png;*.jpeg;*.JPG;*.GIF;*.PNG;','style'=>1,'mode'=>2,'max_num'=>0,'max_size'=>"0",'multi'=>'1','auto'=>'true','thumbImg'=>'无水印|0,文字1|1.png,图片1|2.png','thumb'=>'100X129,121X90','cname'=>"UpFileList","model"=>$_GET["module"]));?>
							
					    
					</td>
					</tr>

					<tr>
					<td>
 <div class="searchnavbox"><ul id="searchnav" class="searchnav">
<li class="cur" data-type="3"><span>全部图组</span></li>
<li  data-type="1"><span>未发售前截图</span></li> 
<li  data-type="2"><span>资源类截图</span></li> 
<li  data-type="0"><span>其他图片</span></li> 
</ul></div>

<script>

 $("#searchnav li").click(function (){ 

     var value=$.trim($("#search").val());
     var type = $(this).attr("data-type");
     var str="";
     var result="";
     if(value.length==0) {
    	 alert("请输入关键词！");
    	 return false;
     }
     else{
     	$.getJSON("/admin/ubutton/ubutton/getpiclist?type="+type+"&keyword="+value+"",function(data){
                     for(var i=0;i<data.length;i++){
                             
                            str+='<div class="showpic" id="'+data[i]['ID']+'"><img src="'+data[i]['indexpicpic']+'" class="showimg" width="145" height="109"/><div>'+data[i]['name']+'</div><div class="nums">'+data[i]['nums']+'</div></div>';

                     }
                     if(parseInt(data)==0) $("#piclist").html("<div style='width:200px;height:100px;line-height:100px;font-weight:bold;font-size:20px;color:#F00;margin:0 auto;'>没有找到相关图片</div>");
                     else $("#piclist").html(str);
                     	     	 
       });
     }
 })
  $("#searchnav li").click(function (){ 
	 $("#searchnav li").removeClass("cur");
	 $(this).addClass("cur");
 })
</script>
						<div id="piclist"></div>
						
					</td>
					</tr>
				                    					
				</tbody>
			</table>
</div>
<style >
.showpic{float:left;margin-left:12px;display:inline-block;margin-top:10px;cursor:pointer;}
</style>
<script type="text/javascript">
        $("#submit").bind("click",function(){
        	     var value=$.trim($("#search").val());
        	     var str="";
        	     var result="";
        	     if(value.length==0) alert("请输入关键词！");
                 else{
                 	$.getJSON("/admin/ubutton/ubutton/getpiclist?keyword="+value+"",function(data){
                                 for(var i=0;i<data.length;i++){
                                         
                                        str+='<div class="showpic" id="'+data[i]['ID']+'"><img src="'+data[i]['indexpicpic']+'" class="showimg" width="145" height="109"/><div>'+data[i]['name']+'</div><div class="nums">'+data[i]['nums']+'</div></div>';

                                 }
                                 if(parseInt(data)==0) $("#piclist").html("<div style='width:200px;height:100px;line-height:100px;font-weight:bold;font-size:20px;color:#F00;margin:0 auto;'>没有找到相关图片</div>");
                                 else $("#piclist").html(str);
                                 	     	 
                   });
                 }
        });
        $("body").delegate(".showpic","click",function(){
        
 
          $url = "/admin/ubutton/ubutton/getpic?id="+$(this).attr("id");
		  art.dialog.open($url,{title:"选择图片",width: '50%', height: '60%', left: '50%', top: '20%', fixed: true, resize: false, drag: false,lock:true,okVal:"插入",
		  ok: function ()
		  { 
		  	   		var iframe = this.iframe.contentWindow;

     
		  	        var result="";
		            var aInput=[];
		            allElements =iframe.document.getElementsByTagName("a"); 


					for(var i=0;i<allElements.length;i++){
		              	if(allElements[i].className=="active"){
		                   	aInput.push(allElements[i]);
		              	}
					}
					if(aInput.length==0){
						alert("请选择图片！");
						return false;
					}
					for(var j=0;j<aInput.length;j++){

                          result+='<img src="'+aInput[j].id+'"/>';
					}

					var iframe_name = $('#right_main',parent.document).attr('name');
					parent.frames[iframe_name].insertpagebreak($("#hid").val(),result);
					this.hide();
              	 　	 
		  },cancel: true,
			close: function () {
				this.hide();
			}});
	


         });
        
        
</script>
<style>
.searchnav  li span{padding: 0 14px; display: block; color: #333;outline: 0;cursor:pointer}
.searchnavbox{background-color: #f7f7f7;border-bottom: 1px solid #dfdfdf;height: 27px;line-height: 28px;margin-bottom: 9px;}
.searchnav{padding-left: 16px;height: 28px;position: relative;top: 0;z-index: 1;}
.searchnav li{float: left;font-size: 14px;}
.rststat{text-align: right;padding-right: 5px;color: #666;margin-top: -32px;}
body{background: #fff;}
.searchnav li.cur{background: url(/admin/public/images/curnav.gif) no-repeat right -32px;padding-right: 18px;color: #439208;}
.searchnav a{padding: 0 14px;display: block;color: #333;outline: 0;}
.searchnav li.cur span{background: url(/admin/public/images/curnav.gif) no-repeat;padding-left: 18px;display: block;color: #439208;}
#piclist{overflow:hidden;width:100%;}
.showpic{ position:relative;width:145px;height:149px;overflow:hidden;text-align:left;font-size:12px;margin:20px;margin-left:8px;margin-right:12px;}
.nums{width:25px;height:25px;background:#1AD554;position:absolute;right:0px; top:0px;line-height:25px	;text-align:center;color:#fff;font-weight:blod;}
</style>